<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="Bookmark" href="/favicon.ico">
    <link rel="Shortcut Icon" href="/favicon.ico" />
    <!--[if lt IE 9]>
                    <script type="text/javascript" src="lib/html5shiv.js"></script>
                    <script type="text/javascript" src="lib/respond.min.js"></script>
                    <![endif]-->
    <link rel="stylesheet" type="text/css" href="../static/h-ui/css/H-ui.min.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/H-ui.admin.css" />
    <link rel="stylesheet" type="text/css" href="../lib/Hui-iconfont/1.0.8/iconfont.css" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/skin/default/skin.css" id="skin" />
    <link rel="stylesheet" type="text/css" href="../static/h-ui.admin/css/style.css" />
    <link rel="stylesheet" href="./../lib/layui/css/layui.css">
    <!--[if IE 6]>
                    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
                    <script>DD_belatedPNG.fix('*');</script>
                    <![endif]-->
    <title>礼包内容修改</title>
    <style>
        .container{
            width: 60%;
            margin: 0 auto;
        }
        input[disabled]{
            background: rgba(0,0,0,0.1)
        }
    </style>
</head>

<body>
    <div class="container">
        <div class="page-container">
            <form action="" method="post" class="form form-horizontal" id="form-article-add">
                <div class="row cl">
                    <label for="" class="form-label col-xs-4 col-sm-3">等级名称：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" id="lv" readonly="readonly" disabled="disabled" value="">
                    </div>
                </div>
                <div class="row cl">
                    <label for="" class="form-label col-xs-4 col-sm-3">单次最高返利额度：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="0" id="discount">
                    </div>
                </div>
                <div class="row cl">
                    <label for="" class="form-label col-xs-4 col-sm-3">折扣：</label>
                    <div class="formControls col-xs-8 col-sm-9">
                        <input type="text" class="input-text" value="0" id="price">
                    </div>
                </div>
            </form>
            <div class="row cl">
                <div class="formControls col-xs-8 col-sm-9">

                </div>
            </div>
            <div style="width:85%;margin:0 auto">
                <table class="layui-hide" id="giftBagList" lay-filter="giftBagList"></table>
            </div>
            <div class="row cl" style="margin:10px 0 0 0">
                <div class="col-xs-4 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <button onClick="save();" class="btn btn-primary radius" type="submit">保存</button>
                </div>
            </div>
        </div>
    </div>
    <script type="text/javascript" src="../lib/jquery/1.9.1/jquery.min.js"></script>
    <script type="text/javascript" src="./../static/js/common.js"></script>
    <script type="text/javascript" src="../lib/layer/2.4/layer.js"></script>
    <script type="text/javascript" src="../static/h-ui/js/H-ui.min.js"></script>
    <script type="text/javascript" src="../static/h-ui.admin/js/H-ui.admin.js"></script>
    <script type="text/javascript" src="./../lib/layui/layui.js"></script>
    <script>
        var parentId = parent.$("#details_id").val();
        $(function () {
            $.ajax({
                type: 'post',
                xhrFields: { withCredentials: true },
                url: admin_url + '/kvmUserLv/userLv',
                data: { tokenUserId: userId, token: token, id: parentId },
                success: function (data) {
                    if (data.code == 200) {
                        // if (data.data.lv == 0) {
                        //     $("#lv").val('大众会员')
                        //     } else if (data.data.lv == 1) {
                        //         $("#lv").val('黄金会员')
                        //     } else if (data.data.lv == 2) {
                        //         $("#lv").val('铂金会员')
                        //     } else if (data.data.lv == 3) {
                        //         $("#lv").val('钻石会员')
                        //     }
                        $("#lv").val(data.data.name)
                        if(data.data.name == '大众会员'){
                            $("#discount").attr('readonly','readonly')
                            $("#discount").attr('disabled','disabled')
                        }
                        $("#discount").val(data.data.amount)
                        $("#price").val(data.data.point)
                    } else {
                        layer.msg(data.msg)
                    }
                }
            })
        })
        function save() {
            if($("#discount").val() == ''){
                layer.msg("请填写单次最高返利额度")
            }else if($("#price").val() == ''){
                layer.msg("请填写返利比率")
            }else{
                var discount = $("#discount").val(),
                price = $("#price").val();
                $.ajax({
                type: 'post',
                xhrFields: { withCredentials: true },
                url: admin_url + '/kvmUserLv/updUsrelv',
                data: { tokenUserId: userId, token: token, id: parentId,amount:discount,point:price },
                success: function (data) {
                    if (data.code == 200) {
                        layer.msg("修改成功", {
                            time: 1000,
                            end: function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                // window.parent.location.reload();
                                $(window.parent.document).find('.layui-laypage-btn').click()
                            }
                        })
                    } else {
                        layer.msg(data.msg)
                    }
                }
            })
            }
         
        }
    </script>
</body>

</html>